package cn.gxa.j229.bug.finance.service.contant.impl;

import cn.gxa.j229.bug.finance.mapper.AdMapper;
import cn.gxa.j229.bug.finance.pojo.Ad;
import cn.gxa.j229.bug.finance.pojo.Loan;
import cn.gxa.j229.bug.finance.service.contant.AdService;
import com.mysql.cj.QueryResult;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author Jun
 * @version 1.0
 * @date 2020/9/22 14:45
 */

@Service("adService")
public class AdServiceImpl implements AdService {

    @Resource
    private AdMapper adMapper = null;

    //@Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.SUPPORTS,rollbackFor = {Throwable.class})
    @Override
    public int delete(Integer id) {
        return adMapper.delete(id);
    }
   // @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.SUPPORTS,rollbackFor = {Throwable.class})
    @Override
    public int insert(Ad ad) {
        return  adMapper.insert(ad);
    }

    @Override
    public List<Map<String,Object>> selectById(Integer id) {
        return adMapper.selectById(id);
    }

    @Override
    public List<Map<String,Object>> selectCount() {
        return  adMapper.selectCount();
    }

    @Override
    public int selectByPageCount(Ad ad) {
        return adMapper.selectByPageCount(ad);
    }
    // @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.SUPPORTS,rollbackFor = {Throwable.class})

    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.SUPPORTS,rollbackFor = {Throwable.class})
    @Override
    public List<Map<String, Object>> selectByTitle(String title) {
        return adMapper.selectByTitle(title);
    }
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.SUPPORTS,rollbackFor = {Throwable.class})
    @Override
    public List<Map<String, Object>> selectByPosition(String position) {
        return adMapper.selectByPosition(position);
    }
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.SUPPORTS,rollbackFor = {Throwable.class})
    @Override
    public List<Map<String, Object>> selectByProvince(String province) {
        return adMapper.selectByProvince(province);
    }
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.SUPPORTS,rollbackFor = {Throwable.class})
    @Override
    public List<Map<String, Object>> selectByState(Integer state) {
        return adMapper.selectByState(state);
    }
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.SUPPORTS,rollbackFor = {Throwable.class})
    @Override
    public List<Map<String, Object>> selectAllProvince( ) {
        return adMapper.selectAllProvince();
    }
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.SUPPORTS,rollbackFor = {Throwable.class})
    @Override
    public List<Map<String, Object>> selectAllPosition( ) {
        return adMapper.selectAllPosition();
    }
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.SUPPORTS,rollbackFor = {Throwable.class})
    @Override
    public  List<Map<String,Object>> selectAdByPage(Ad ad) {
        ad.setLimit((ad.getLimit() - 1) * ad.getPage());
        return adMapper.selectByPage(ad);

    }
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.SUPPORTS,rollbackFor = {Throwable.class})
    @Override
    public int update(Ad record) {
        return adMapper.update(record);
    }
}
